package udp.udpdict;
import udp.udpecho.UdpEchoSever;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;

public class UdpDictSever extends UdpEchoSever {
    private HashMap<String, String> dict = new HashMap<>();
    public UdpDictSever(int port) throws SocketException {
        super(port);
        dict.put("小猫", "cat");
        dict.put("小狗", "dog");
        dict.put("你好", "hello");
    }

    @Override
    public String process(String request) {
        return dict.getOrDefault(request, "未找到改词条");
    }

    public static void main(String[] args) throws IOException {
        UdpDictSever udpDictSever = new UdpDictSever(9090);
        udpDictSever.start();
    }
}
